<?php

/**
 * index actions.
 *
 * @package    ingenyo-biblio
 * @subpackage index
 * @author     ivan
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class indexActions extends sfActions
{

  /**
   * Executes index action
   *
   * @param sfRequest $request A request object
   */
  public function executeIndex(sfWebRequest $request)
  {
    $this->getUser()->setAttribute('index', true);
    $this->getUser()->clearAttribute('nuevo');
    #reservas
    $cantidad = sfConfig::get('app_index_cant_items');
    $this->reservas_que_se_retiran = BbReservalibroPeer::getReservasProximas($cantidad);
    $this->reservas_links = Array();
    foreach ($this->reservas_que_se_retiran as $key => $reserva)
    {
      $this->reservas_links[] = $this->generateUrl('bb_reserva_libro_show', $reserva);
    }
    $this->reservas_que_se_retiran = count($this->reservas_que_se_retiran) > 0 ? $this->reservas_que_se_retiran : null;
    #prestamos
    $this->prestamos_que_vencen = BbPrestamoPeer::getPrestamosProximos($cantidad);
    $this->prestamos_links = Array();
    foreach ($this->prestamos_que_vencen as $key => $prestamo)
    {
      $this->prestamos_links[] = $this->generateUrl('bb_prestamo_show', $prestamo);
    }
    $this->prestamos_que_vencen = count($this->prestamos_que_vencen) > 0 ? $this->prestamos_que_vencen : null;
    $this->ultimos_comentarios = CtDocumentoComentarioPeer::getUltimosComentarios($cantidad);

    $this->setLayout('layout');

  }

}
